package com.csc.finalproject.dao;

import java.util.List;
import java.util.Map;

import javax.persistence.EntityManager;
import javax.persistence.EntityTransaction;
import javax.persistence.Query;
import javax.persistence.TypedQuery;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import org.springframework.stereotype.Repository;
import org.springframework.web.bind.annotation.ResponseStatus;

import com.csc.finalproject.domain.AccountInfo;
import com.csc.finalproject.domain.State;
import com.csc.finalproject.domain.User;

@Repository("userDAO")
public class UserDAOImpl extends GenericDAOImpl<User> implements UserDAO {

	public User getUser(String login) {
		TypedQuery<User> query = em.createQuery(
				"SELECT u FROM User u WHERE u.login=:login", User.class);
		query.setParameter("login", login);
		List<User> user = query.getResultList();
		if (user.size() > 0) {
			return user.get(0);
		}
		return null;
	}

}